//package cn.com.bmsoft.smartcity.apis.portal.filter;
//
//import OutOfBusinessException;
//import org.springframework.boot.web.servlet.DelegatingFilterProxyRegistrationBean;
//import org.springframework.context.annotation.Bean;
//import org.springframework.stereotype.Component;
//
//import javax.servlet.*;
//import javax.servlet.http.HttpServletRequest;
//import java.io.IOException;
//
//@Component
//public class AuthFilter {
//
//    @Bean("proxyFilter")
//    public Filter filter() {
//        return new Filter() {
//            @Override
//            public void init(FilterConfig filterConfig) throws ServletException {
//            }
//
//            @Override
//            public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
//                HttpServletRequest req = (HttpServletRequest) request;
//                if ("/oauth/token".equals(req.getRequestURI())) {
//                    chain.doFilter(request, response);
//                } else {
//                    if (req.getSession(false) == null) {
//                        throw new OutOfBusinessException("请求未授权");
//                    } else {
//                        if (req.getHeader("Authorization") == null || "".equals(req.getHeader("Authorization")) || !"YzFzMQ==".equals(req.getHeader("Authorization"))) {
//                            throw new OutOfBusinessException("请求未授权");
//                        } else {
//                            chain.doFilter(request, response);
//                        }
//
//                    }
//                }
//
//
//            }
//
//            @Override
//            public void destroy() {
//            }
//        };
//    }
//
//    @Bean
//    public DelegatingFilterProxyRegistrationBean delegatingFilterProxyRegistrationBean() {
//        DelegatingFilterProxyRegistrationBean bean = new DelegatingFilterProxyRegistrationBean("proxyFilter");
//        bean.addUrlPatterns("/*");
//        return bean;
//    }
//
//}
